#include"sequenceList.h"
void SLInit(SL* slp)
{
    assert(slp);
    slp->a = (SLDateType*)malloc(sizeof(SLDateType)*INITCAPACITY);
    if(slp->a==NULL)
    {
        perror("malloc file");
        return ;
    }
    slp->capacity = INITCAPACITY;
    slp->size = 0;
}

void SLDestroy(SL* slp)
{
    assert(slp);
    free(slp->a);
    slp->a = NULL;
}

void SLPrint(SL* slp)
{
    assert(slp);
    for(int i = 0;i<slp->size;i++)
    {
        printf("%d ",slp->a[i]);
    }
}

void SLPushBack(SL* slp,SLDateType x)
{
    assert(slp);
    if(slp->size==slp->capacity)//扩容
    {
        SLDateType* tmp = (SLDateType*)realloc(slp->a,slp->capacity*2*sizeof(SLDateType));
        if(tmp==NULL)
        {
            perror("realloc");
            return ;
        }
        slp->a = tmp;
        slp->capacity *=2;
    }
    slp->a[slp->size] = x;
    slp->size++;
}

void SLPopBack(SL* slp)
{
    assert(slp);
    slp->size--;
}